package com.link.base.base.common.service;

import com.link.base.base.common.model.Announce;
import com.link.base.base.common.model.Attachment;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.ServiceException;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * Copyright  hande Company. All Rights Reserved.
 *
 * @author unknwon
 * @version 1.0
 * @date: 2018/11/8 19:31
 */

public interface AttachmentService extends BasicService<Attachment> {

    /**
     * 单个附件上传
     *
     * @param record
     * @param myfile
     * @throws ServiceException
     */
    public void upload(MultipartFile myfile, Attachment record) throws ServiceException;

    /**
     * 删除文件
     *
     * @param filePath 文件的服务器路径
     * @throws ServiceException
     */
    public void fileDelete(String filePath) throws ServiceException;

    /**
     * 查询资源库列表
     *
     * @param record
     * @return
     * @throws Exception
     */
    public List<Attachment> queryAttachmentLibraryListPage(Attachment record) throws Exception;

    /**
     * 上传文件并且新建附件记录
     *
     * @param myfile 文件
     * @param entity 附件对象
     * @return 生成的附件对象
     * @throws Exception
     */
    public Attachment insert(MultipartFile myfile, Attachment entity) throws Exception;




    /* ---------------------------------------------------------------------------------- */

    /**
     * 附件上传，其中方法的参数为MultipartFile[]
     *
     * @param myfiles
     * @return 附件对象
     * @throws ServiceException
     */
    public List<Attachment> attachmentUpload(MultipartFile[] myfiles) throws ServiceException;

    /**
     * 附件上传，其中方法的参数为List
     *
     * @param myfiles
     * @return
     * @throws ServiceException
     */
    public List<Attachment> attachmentListUpload(List<MultipartFile> myfiles) throws ServiceException;

    /**
     * 上传附件并覆盖原有附件
     *
     * @param myfiles
     * @return
     * @throws ServiceException
     */
    public List<Attachment> attachmentUploadAndCover(MultipartFile[] myfiles) throws ServiceException;

    /**
     * 查询公告下的附件列表
     *
     * @param record
     * @return
     * @throws ServiceException
     */
    public List<Attachment> queryAttachmentListByAnnounceId(Announce record) throws ServiceException;

    /**
     * 编辑公告时，删除公告下的附件
     *
     * @param record
     * @throws ServiceException
     */
    public void deleteAttachmentInAnnounceId(Attachment record) throws ServiceException;

    /**
     * 根据附件Id查询附件隶属的公告信息
     *
     * @param record
     * @return
     * @throws ServiceException
     */
    public Announce queryAnnouceByAttachmentId(Attachment record) throws ServiceException;

    /**
     * s
     * <p></p>
     *
     * @param ids 文件id字符串组
     * @return 生成压缩包的url
     * @a多文件打包下载uthor yrf
     */
    public String batchDownload(String[] ids);

    /**
     * 邮件附件上传，其中方法的参数为List
     *
     * @param myfiles
     * @return
     * @throws ServiceException
     */
    public List<Attachment> emailAttachmentUpload(List<MultipartFile> myfiles) throws ServiceException;

    /**
     * 删除邮件附件
     *
     * @param fileName
     * @throws ServiceException
     */
    public void emailAttachmentDelete(String fileName) throws ServiceException;

    /**
     * 下载邮件附件
     *
     * @param fileName
     * @param response
     * @throws ServiceException
     */
    public void emailAttachmentDownload(String fileName, HttpServletResponse response) throws ServiceException;


    /***
     * 通过headID删除附件
     * @param attachment
     * @throws Exception
     */
    public void deleteByHeadId(Attachment attachment) throws Exception;

    /**
     * <p>根据id查询附件</p>
     * @author yrf
     * @param attachment
     * @return
     * @throws Exception
     */
    public List<Attachment> queryAttachmentByHeadId(Attachment attachment) throws Exception;

    /**
     * 通过头id查询附件
     *
     * @param headId
     * @return
     * @throws Exception
     */
    public Attachment queryVoiceAttachmentByHeadId(Long headId) throws Exception;

    /**
     * 删除附件
     *
     * @param id
     * @throws ServiceException
     */
    public void deleteAttachentById(Long id) throws ServiceException;

    /**
     * 单个语音附件上传
     *
     * @param myfile
     * @param record
     * @return
     * @throws ServiceException
     */
    public Attachment voiceFileUpload(MultipartFile myfile, Attachment record) throws ServiceException;

    /**
     * 根据Id更新头Id信息
     *
     * @param attachment
     * @throws Exception
     */
    public void attachmentHeadIdUpdate(Attachment attachment) throws Exception;

    /**
     * 批量删除文件
     * @author wangdawei
     * @param attachmentList
     * @return
     */
    public Map<String,Object> batchDeleteAttch(List<Attachment> attachmentList) throws Exception;

    /**
     * 根据filtersRaw查询附件，用来区别之前标准查询方法
     *
     * @author LiYang
     * @date 20191209
     */
    public List<Attachment> queryByFilterPage(Attachment attachment) throws Exception;

    /**
     * 无登录情况下上传附件
     *
     * @author 路江
     * @date 2019-12-24
     * @param myfile 附件文件
     * @param entity 附件信息
     * @return
     * @throws Exception
     */
    public Attachment insertAttachment(MultipartFile myfile, Attachment entity) throws Exception;

    /**
     * COS - 获取临时秘钥
     *
     * @author 李莹
     * @date 2020/07/01 04:15
     */
    public Map<String, Object> getTmpSecret(Attachment entity) throws Exception;

    /**
     * COS - 获取单个文件预签名URL
     *
     * @author 李莹
     * @date 2020/07/03 05:38
     */
    public Map<String, Object> getSingleAttachmentUrl(Attachment entity) throws Exception;

}
